import os

import pandas as pd

from src.util.common_util import printx
from src.util.config_manager import ConfigManager


def merge_files_entrance(config: ConfigManager) -> None:
    folder = input(f"请输入文件夹位置:")
    outfile = input(f"请输入输出文件名:")
    csv_files = [f for f in os.listdir(folder) if f.endswith('.csv')]
    df_list = [pd.read_csv(f"{folder}/{f}").reset_index(drop=True) for f in csv_files]
    merged_df = pd.concat(df_list, ignore_index=True)
    merged_df.to_csv(os.path.join(folder, outfile), index=False)
    printx(f"合并完成，保存为{outfile}")
